from rest_framework import serializers
from apps.goods.models import SPUSpecification


class SPUSpecificationSerialzier(serializers.ModelSerializer):
    """
                "id": "规格id",
                "name": "规格名称",
                "spu": "SPU商品名称",
                "spu_id": "SPU商品id"
    """
    # 关联嵌套返回
    spu = serializers.StringRelatedField(read_only=True)
    spu_id = serializers.IntegerField()

    class Meta:
        model = SPUSpecification
        fields = '__all__'
